<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Introduction - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/learning.layout.intro.html">Inglês (English)</a></li>
    <li><a href="../pt-br/learning.layout.intro.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="learning.layout.html">Getting Started with Zend_Layout</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="learning.layout.html">Getting Started with Zend_Layout</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="learning.layout.usage.html">Using Zend_Layout</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="learning.layout.intro" class="section"><div class="info"><h1 class="title">Introduction</h1></div>
    

    <p class="para">
        When building a website using Zend Framework <acronym class="acronym">MVC</acronym> layers, your view
        scripts will typically be just snippets of <acronym class="acronym">HTML</acronym> pertinent to the
        requested action. For instance, if you had the action &quot;<var class="filename">/user/list</var>&quot;,
        you might create a view script that iterates through the users and presents an unordered
        list:
    </p>

    <pre class="programlisting brush: php">
&lt;h2&gt;Users&lt;/h2&gt;
&lt;ul&gt;
    &lt;?php if (!count($this-&gt;users)): ?&gt;
    &lt;li&gt;No users found&lt;/li&gt;
    &lt;?php else: ?&gt;
    &lt;?php foreach ($this-&gt;users as $user): ?&gt;
    &lt;li&gt;
        &lt;?php echo $this-&gt;escape($user-&gt;fullname) ?&gt;
        (&lt;?php echo $this-&gt;escape($user-&gt;email) ?&gt;)
    &lt;/li&gt;
    &lt;?php endforeach ?&gt;
    &lt;?php endif ?&gt;
&lt;/ul&gt;
</pre>


    <p class="para">
        Since this is just a snippet of <acronym class="acronym">HTML</acronym>, it&#039;s not a valid page; it&#039;s missing
        a <acronym class="acronym">DOCTYPE</acronym> declaration, and the opening <acronym class="acronym">HTML</acronym> and
        <acronym class="acronym">BODY</acronym> tags. So, the question is, where will these be created?
    </p>

    <p class="para">
        In early versions of Zend Framework, developers often created &quot;header&quot; and &quot;footer&quot; view
        scripts that had these artifacts, and then in each view script they would render them. While
        this methodology worked, it also made it difficult to refactor later, or to build composite
        content by calling multiple actions.
    </p>

    <p class="para">
        The <a href="http://martinfowler.com/eaaCatalog/twoStepView.html" class="link external">&raquo; Two Step View</a>
        design pattern answers many of the issues presented. In this pattern, the &quot;application&quot; view
        is created first, and then injected into the &quot;page&quot; view, which is then presented to the
        client. The page view can be thought of as your site-wide template or layout, and would have
        common elements used across various pages.
    </p>

    <p class="para">
        Within Zend Framework, <span class="classname">Zend_Layout</span> implements the Two Step View
        pattern.
    </p>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="learning.layout.html">Getting Started with Zend_Layout</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="learning.layout.html">Getting Started with Zend_Layout</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="learning.layout.usage.html">Using Zend_Layout</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="learning.html">Learning Zend Framework</a></li>
  <li class="header up"><a href="learning.layout.html">Getting Started with Zend_Layout</a></li>
  <li class="active"><a href="learning.layout.intro.html">Introduction</a></li>
  <li><a href="learning.layout.usage.html">Using Zend_Layout</a></li>
  <li><a href="learning.layout.conclusions.html">Zend_Layout: Conclusions</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>